/*
 * @Author: bclz
 * @Date: 2022-02-08 11:23:28
 * @LastEditTime: 2022-02-08 13:52:46
 * @LastEditors: bclz
 * @Description: no description
 */
/**
 * Created by HZH
 * Date-Time: 2022-01-26
 */

import React, { useRef, useState } from 'react';
import { Button, Tabs, DisconnectOutlined } from 'antd';

import { Disconnect } from '@ant-design/icons';
import { TheContainer, TheTable } from '@/components';
import { getProjectList } from '@/services/project/list';
import { useRequest } from 'ahooks';
import { DeviceCard } from './components';
import styles from './index.less';

const { TabPane } = Tabs;

const getList = async function () {
  const data = [
    {
      id: '0',
      name: '名称',
      creator: '黄忠浩',
      editor: '前端',
      desc: '描述信息',
      createTime: new Date(),
      updateTime: new Date(),
      status: '0',
    },
  ];
  return {
    data: data,
    current: 1,
    pageSize: '20',
    total: 25,
    success: true,
  };
};

const tabList = [
  {
    name: '智能开关',
    type: '1',
  },
  {
    name: '新风系统',
    type: '4',
  },
  {
    name: '恒温系统',
    type: '5',
  },
  {
    name: '温度、湿度、光照',
    type: '6',
  },
  {
    name: '智能电表',
    type: '7',
  },
  {
    name: '智能水表',
    type: '8',
  },
  {
    name: '电器火灾',
    type: '2',
  },
  {
    name: '水位水压',
    type: '3',
  },
];

const tabDataItem = {
  connectType: 0, // 0在线，1不在线
  status: 0, // 0正常，1异常
  id: 1,
  type: 'none',
  image: '',
  uuid: '98CC4D212335',
  equipmentId: 'DEV-98CC4D212335',
  info: '江门电视台江门市蓬江区丰乐路育德街乐美路4-1怡雅苑212335',
};

const getTabData = async () => {
  return [
    tabDataItem,
    {
      connectType: 1, // 0在线，1不在线
      status: 1, // 0正常，1异常
      id: 2,
      type: 'none',
      image: '',
      uuid: '98CC4D212335',
      equipmentId: 'DEV-98CC4D212335',
      info: '江门电视台江门市蓬江区丰乐路育德街乐美路4-1怡雅苑212335',
    },
    {
      connectType: 0, // 0在线，1不在线
      status: 0, // 0正常，1异常
      id: 3,
      type: 'none',
      image: '',
      uuid: '98CC4D212335',
      equipmentId: 'DEV-98CC4D212335',
      info: '江门电视台江门市蓬江区丰乐路育德街乐美路4-1怡雅苑212335',
    },
  ];
};

export default () => {
  const actionRef = useRef();

  const handleSetSelectedRowKeys = (val) => {
    setSelectedRowKeys(val);
  };

  const { data: tabData = [] } = useRequest(getTabData, {
    formatResult: (res) => {
      return res;
    },
  });

  return (
    <div className={styles.innerContent}>
      <Tabs defaultActiveKey="1" onChange={(callback) => {}}>
        {tabList.map((tabItem) => {
          return (
            <TabPane tab={tabItem.name} key={tabItem.type}>
              <DeviceCard data={tabData} />
            </TabPane>
          );
        })}
        {/* <TabPane tab="Tab 1" key="1">

        </TabPane>
        <TabPane tab="Tab 2" key="2">
          Content of Tab Pane 2
        </TabPane>
        <TabPane tab="Tab 3" key="3">
          Content of Tab Pane 3
        </TabPane> */}
      </Tabs>
    </div>
  );
};
